// JavaScript Document
$(function () {
	initModify();
	//提交
	$(".submit").on("click",function(){
		checkModify();
	});
});
//初始化
function initModify(){
	CKEDITOR.replace( 'crtamContent' , { height: '240px', 
		width: '480px',
		toolbar: [['Source','-','Preview'],
		          ['Cut','Copy','Paste','PasteText','PasteFromWord'],
		          ['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
		          ['Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField'],
		          ['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],
		           ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
		           ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
		           ['Link','Unlink'],
		          ['Image','Table','HorizontalRule','Smiley'],
		           ['Styles','Format','Font','FontSize'],
		           ['TextColor','BGColor']],
		extraPlugins: 'codesnippet',
		uiColor: '#f3f3f3'
	} );
	getInfo("AAAAA");	
}
//获取详情
function getInfo(id){
	var str = 'crtamUuid='+encodeURIComponent(id);
	getOData(str,"coreTeam/views",{fn:function(oData){
		if(oData.code == 1) {
			CKEDITOR.instances.crtamContent.setData(oData.data.crtamContent);
		} else {
			alert(data.errMsg);
		}
	}});
}
//检查提交
function checkModify(){
	if($.trim(CKEDITOR.instances.crtamContent.getData()) == ""){
		alert("内容不能为空，请填写完再提交！");
		return false;
	}
	var r=confirm("是否确认修改？");
	if (r==true){
		var msgObject = parent.layer.msg('处理中，请等待……', {
			icon: 16,
			shade: 0.4,
			time: waitImgTime //（如果不配置，默认是3秒）
		}, function(index){
			//do something
			parent.layer.close(index);
		});
		Modify(msgObject);
	}
}
//提交
function Modify(msgObject){
	var crtamUuid = "AAAAA";
	var crtamContent = CKEDITOR.instances.crtamContent.getData();
	var str = 'crtamUuid='+encodeURIComponent(crtamUuid)+'&crtamContent='+encodeURIComponent(crtamContent);
	getOData(str,"coreTeam/update/coreTeam",{
		fn:function(oData){
			parent.layer.close(msgObject);
			alert("修改成功！");		
		},
		fnerr:function(oData){
			parent.layer.close(msgObject);
		}
	});
}